<!-- inc:frame.top -->

<!-- if(!$single) -->
<div class="position"><p><!-- inc:position --> &raquo; <a href="{:$mainlink}?file=upfiles&act=list">文件管理</a> &raquo; 附件管理</p><!-- inc:position.fr --></div>
<!-- end -->

<!-- if($sysAct == "list") -->
<script type="text/javascript">
function qg_delete(id)
{
	if(!id || id == "0")
	{
		tip_alert("ID号不允许为空！");
		return false;
	}
	url = "{:$mainlink}?file=upfiles&act=delete&id="+id;
	tip_confirm("确认删除该附件吗？特别说明，删除后无法恢复！",url);
	return true;
}

function qg_delete_all()
{
	var idarray = new Array();//定义一个数组
	var cv = document.getElementsByTagName("input");
	var m = 0;
	for(var i=0; i<cv.length; i++)
	{
		if(cv[i].type.toLowerCase() == "checkbox")
		{
			if(cv[i].checked)
			{
				idarray[m] = cv[i].value;
				m++;
			}
		}
	}
	var id = idarray.join(",");
	if(!id || id == "0")
	{
		tip_alert("没有勾选要操作的主题！");
		return false;
	}
	var url;
	url = "{:$mainlink}?file=upfiles&act=delete&idlist="+id;
	tip_confirm("确认删除该信息吗？特别说明，删除后无法恢复！",url);
}

function upfile_viewpic(id)
{
	var url = "{:$mainlink}?file=open.viewpic&id="+id;
	qg_open(url,"500");
}
</script>

<script type="text/javascript">
$(function(){
	$(".upfiles_part .pic").click(function () {
		upart = $(this).parents(".upfiles_part");
		cbox = upart.find("input[type='checkbox']")
		if(cbox.prop("checked")==true)
		{
			upart.removeClass("upfiles_part_on");
			cbox.prop("checked",false).attr("checked",false);
		}
		else
		{
			upart.addClass("upfiles_part_on");
			cbox.prop("checked",true).attr("checked",true);
		}
	});
	
	$("#extlist tr").click(function () {
		cbox = $(this).find("input[type='checkbox']")
		if(cbox.prop("checked")==true)
		{
			$(this).removeClass("selected");
			cbox.prop("checked",false).attr("checked",false);
		}
		else
		{
			$(this).addClass("selected");
			cbox.prop("checked",true).attr("checked",true);
		}
	});
	
	$("#piclist").find("input[type='checkbox']").click(function () {
		upsele();
	});
});

//选择后修改样式
function upsele()
{
	cbox_all = $("#piclist").find("input[type='checkbox']");
	$(cbox_all).each(function(){
		if($(this).prop("checked")==true)
		{
			$(this).parents(".upfiles_part").addClass("upfiles_part_on");
		}
		else
		{
			$(this).parents(".upfiles_part").removeClass("upfiles_part_on");
		}
	});
}

//选择后修改样式
function upsele2()
{
	cbox_all = $("#extlist").find("input[type='checkbox']");
	$(cbox_all).each(function(){
		if($(this).prop("checked")==true)
		{
			$(this).parents("tr").addClass("selected");
		}
		else
		{
			$(this).parents("tr").removeClass("selected");
		}
	});
}
</script>

<div class="page_pad">
  <!-- if($piclist) -->
  <div class="content_box">
    <div class="content_bor">
      <div id="piclist" class="upfiles_page">
        <!-- $piclist AS $key=>$value -->
        <div class="upfiles_part">
          <div class="pad">
            <div class="pic"><img src="{:$value[thumb]}" /></div>
            <div class="word">
            <form method="post" action="{:$mainlink}?file=upfiles&act=modifyok&id={:$value[id]}">
              <p><input class="ginput upfiles_ginput" type="text" name="tmpname" value="{:$value[tmpname]}" /></p>
              <p><input type="checkbox" name="qg_id[]" value="{:$value[id]}" style="position:relative; top:2px;" />&nbsp;<button class="gbutton gbutton_min" type="submit">更改</button>&nbsp;&nbsp;<button class="gbutton gbutton_min" type="button" onclick="qg_delete({:$value[id]})">删除</button><span class="magnifier" onclick="upfile_viewpic({:$value[id]});"><i class="icon-magnifier"></i></span></p>
            </form>
            </div>
          </div>
        </div><!--upfiles_part-->
	    <!-- end -->
        <div class="clear"></div>
      </div><!--upfiles_page-->
    </div>
  </div><!--content_box-->
  
  <!-- else -->
  <table class="qg_notice">
    <tr>
      <td>暂无上传附件。<a href="{:$mainlink}?file=upfiles&act=upfiles">上传附件</a>。</td>
    </tr>
  </table>
  <!-- end -->
  
  <!-- if($get_count>0) -->
  <div class="content_ctrl">
    <button class="gbutton gbutton_min" type="button" onclick="select_all('piclist');upsele();">全选</button>
    <button class="gbutton gbutton_min" type="button" onclick="revCheck('piclist');upsele();">反选</button>
    <button class="gbutton gbutton_min" type="button" onclick="selectNone('piclist');upsele();">全不选</button>
    <button class="gbutton gbutton_min" type="button" onclick="qg_delete_all()">批量删除</button>
    
    <div class="content_pagelist">{:$pagelist}</div>
  </div><!--content_ctrl-->
  <!-- end -->
  
  <!-- if($attlist && is_array($attlist)) -->
  <table class="qg_notice">
    <tr>
      <td>可下载附件</td>
    </tr>
  </table>
  <!-- $attlist AS $key=>$value -->
  <table class="ltable">
    <tr>
      <td width="250">
        <form method="post" action="{:$mainlink}?file=upfiles&act=modifyok&id={:$value[id]}">
        <table class="ntable ptable">
          <tr>
            <td><input class="ginput" type="text" name="tmpname" value="{if($value[tmpname])}{:$value[tmpname]}{else}{:$value[filename]}{end}" style="width:200px;"></td>
            <td>&nbsp;&nbsp;</td>
            <td><button class="gbutton gbutton2" type="submit">更改</button></td>
          </tr>
        </table>
        </form>
      </td>
      <td align="center"><a href="{:$value[folder]}{:$value[filename]}" target="_blank" title="下载附件"><img style="position:relative; top:2px;" src="images/download.gif" title="下载附件" /></a>&nbsp;{:$value[filesize]}</td>
      <td width="230" align="right" title="上传时间：{:$value[postdate]}">{:$value[postdate]}</td>
      <td width="20"><img src="images/files_del.gif" border="0" onclick="qg_delete({:$value[id]})" title="删除该附件" style="cursor:pointer;"></td>
    </tr>
  </table>
  <!-- end -->
  <!-- end -->

  <!-- if($extlist && is_array($extlist)) -->
  <table class="qg_notice">
  <tr>
    <td>其他附件（外部链接或不存的附件）</td>
  </tr>
  </table>
  
  <table id="extlist" class="ltable">
    <!-- $extlist AS $key=>$value -->
    <tr>
      <td width="30"><div class="check_zw"><input type="checkbox" name="filelist[]" value="{:$value[id]}"><span></span></div></td>
      <td width="250" align="left"><input class="ginput" type="text" name="tmpname" value="{if($value[tmpname])}{:$value[tmpname]}{else}{:$value[filename]}{end}" disabled></td>
      <td>{:$value[folder]}{:$value[filename]}</td>
      <td width="260" align="right">{:$value[postdate]}</td>
      <td width="20"><img src="images/files_del.gif" border="0" onclick="qg_delete({:$value[id]})" title="删除该附件" style="cursor:pointer;"></td>
    </tr>
    <!-- end -->
  </table>
  
  <div class="content_ctrl">
    <button class="gbutton gbutton_min" type="button" onclick="select_all('extlist');upsele2();">全选</button>
    <button class="gbutton gbutton_min" type="button" onclick="revCheck('extlist');upsele2();">反选</button>
    <button class="gbutton gbutton_min" type="button" onclick="selectNone('extlist');upsele2();">全不选</button>
    <button class="gbutton gbutton_min" type="button" onclick="qg_delete_all()">批量删除</button>
  </div><!--content_ctrl-->
  <!-- end -->
</div><!--page_pad-->

<!-- elseif($sysAct == "upfiles") -->
<script>
function changese(obj)
{
	if(obj.value!=0)
	{
		window.location.href="{:$mainlink}?file=upfiles&act=upfiles&sysgroupid="+obj.value+"{if($single)}&single={:$single}{end}";
	}
	else
	{
		window.location.href="{:$mainlink}?file=upfiles&act=upfiles{if($single)}&single={:$single}{end}";
	}
}
</script>
<!-- if($type == "new") -->
<script src="js/plupload/plupload.full.min.js" type="text/javascript"></script>
<link href="js/plupload/plupload.css" type="text/css" rel="stylesheet" />

<div class="page_pad">
  <table class="qg_notice">
    <tr>
      <td>您正在使用多文件上传工具。遇到问题？请尝试使用<a href="{:$mainlink}?file=upfiles&act=upfiles&type=standard{if($sysgroupid)}&sysgroupid={:$sysgroupid}{end}{if($cateid)}&cateid={:$cateid}{end}{if($additonid)}&additonid={:$additonid}{end}{if($single)}&single={:$single}{end}">标准浏览器上传工具</a>。<!-- if($single) --><a class="red" href="{:$mainlink}?file=upfiles&act=upfiles&sysgroupid={:$sysgroupid}&cateid={:$cateid}{if($additonid)}&additonid={:$additonid}{end}" target="_blank">在新窗口打开</a><!-- end --></td>
    </tr>
  </table>
  
  <div class="content_box">
    <div class="content_bor">
      <table class="ctable">
        <tr {if($additonid)}style="display:none;"{end}>
          <td class="left">系统组：</td>
          <td class="right">
            <select class="upselect" name="sysgroupid" onchange="changese(this)">
              <option value="0">未选择</option>
              <!-- $sysmenu AS $key=>$value -->
              <option value="{:$value[id]}" {if($value[id]==$sysgroupid)}selected="selected"{end}>{:$value[groupname]}</option>
              <!-- end -->
            </select>
          </td>
        </tr>
        <!-- if($sysgroupid) -->
        <tr>
          <td class="left">分类：</td>
          <td class="right">
            <table class="ntable ptable2">
              <tr>
                <!-- if($msglist) -->
                <td>
                <select class="upselect" name="cateid" id="cateid" disabled="disabled">
                  <!-- $catelist AS $key=>$value -->
                  <option value="{:$value[id]}" {if($value[id]==$cateid)}selected="selected"{end}>{:$value[space]}{:$value[catename]}</option>
                  <!-- end -->
                </select>
                </td>
                <td>&nbsp;</td>
                <td>
                <select class="upselect" name="additonid" id="additonid" onchange="upoption('url')" style="max-width:250px;">
                  <option value="0">请选择所属内容</option>
                  <!-- $msglist AS $key=>$value -->
                  <option value="{:$value[id]}" {if($value[id]==$additonid)}selected="selected"{end}>{:$value[subject]}</option>
                  <!-- end -->
                </select>
                </td>
                
                <!-- else -->
                <td>
                <select class="upselect" name="cateid" id="cateid" onchange="upoption('url')">
                  <!-- $catelist AS $key=>$value -->
                  <option value="{:$value[id]}" {if($value[id]==$cateid)}selected="selected"{end}>{:$value[space]}{:$value[catename]}</option>
                  <!-- end -->
                </select>
                </td>
                <!-- end -->
              </tr>
            </table>
          </td>
        </tr>
        <!-- end -->
        <tr>
          <td class="left">图片尺寸：</td>
          <td class="right">
            <table class="ntable">
              <tr>
                <td>图片宽度&nbsp;</td>
                <td><input class="ginput ginput_min" style="width:100px" type="text" name="width" id="width" placeholder="像素(px)" onblur="thisnum(this);upoption('resize')" /></td>
                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;图片高度&nbsp;</td>
                <td><input class="ginput ginput_min" style="width:100px" type="text" name="height" id="height" placeholder="像素(px)" onblur="thisnum(this);upoption('resize');" /></td>
                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;提示：宽高只填其中一个，另一个会自动调整</td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td class="left">是否压缩图片：</td>
          <td class="right">
            <table class="ntable">
              <tr>
                <td><input type="checkbox" name="ifreduce" id="ifreduce" onchange="upoption('resize')" /></td>
                <td>&nbsp;是否压缩图片</td>
                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;提示：建议图片大于<span style="color:red";>1M</span>时才开启，小图片启用时会导致图片比原来的更大</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </div>
  </div><!--content_box-->
  
  <div class="upfiles_box">
    <div class="bor">
      <div class="upfiles_pa">
        <div class="upfiles_zw"></div>
        <div id="drag-area">
          <div class="upfiles_tip">
            <div class="h1">把要上传的文件拖放到这里</div>
            <div class="h2">或</div>
            <div class="btn-wraper"><button class="gbutton" type="button" id="browse">选择文件</button></div>
          </div><!--upfiles_tip-->
        </div>
      </div><!--upfiles_pa-->
    </div><!--bor-->
    
    <div class="upfiles_ul">
      <div id="file-list">
      </div><!--file-list-->
    </div><!--upfiles_ul-->
  </div><!--upfiles_box-->
</div><!--page_pad-->
<script>
//修改上传参数
function upoption(option)
{
	$("#file-list").html("");
	if(option=="url")
	{
		uploader.setOption('url','{:$mainlink}?file=upfiles&act=newupfilesok{if($sysgroupid)}&sysgroupid={:$sysgroupid}&cateid='+get_selected('cateid')+'{end}{if($additonid)}&additonid='+get_selected('additonid')+'{end}');
	}
	else if(option=="resize")
	{
		width = document.getElementById("width").value;
		height = document.getElementById("height").value;
		if(document.getElementById("ifreduce").checked)
		{
			ifreduce = 1;
		}
		else
		{
			ifreduce = 0;
		}
		resize_option = new Object;
		if(width!=0)
		{
			resize_option.width = width;
		}
		if(height!=0)
		{
			resize_option.height = height;
		}
		if(ifreduce!=0)
		{
			resize_option.quality = 65;
		}
		uploader.setOption('resize',resize_option);
	}
}

	var uploader = new plupload.Uploader({ //实例化一个plupload上传对象
		browse_button : 'browse',
		url : '{:$mainlink}?file=upfiles&act=newupfilesok{if($sysgroupid)}&sysgroupid={:$sysgroupid}&cateid='+get_selected('cateid')+'{end}{if($additonid)}&additonid='+get_selected('additonid')+'{end}',
		flash_swf_url : 'js/plupload/Moxie.swf',
		silverlight_xap_url : 'js/plupload/Moxie.xap',
		//resize : {quality:60},
		filters : {
			// Maximum file size
			max_file_size : '10mb',
			// Specify what files to browse for
			mime_types: [
				{title : "Image files", extensions : "jpg,jpeg,gif,png"}
			]
		},
		dragdrop: true,
		drop_element : 'drag-area'
	});
	uploader.init(); //初始化
	
	//绑定文件添加进队列事件
	uploader.bind('FilesAdded',function(uploader,files){
		$("#file-list").html("");
		$(".upfiles_zw").show();
		//return false;*/
		for(var i = 0, len = files.length; i<len; i++){
			var file_name = files[i].name; //文件名
			//构造html来更新UI
			var html = '<div id="file-'+files[i].id+'" class="upfiles_li"><div class="word"><div class="fl">'+file_name+'</div><div class="fr"><div class="progress"><p>0%</p><div class="progress-bar progress-bar-info"></div></div></div><div class="clear"></div></div></div>';
			$("#file-list").append(html);
		}
		uploader.start();
	});

	//绑定文件上传进度事件
	uploader.bind('UploadProgress',function(uploader,file){
		//控制进度条
		if(file.percent==100)
		{
			$('#file-'+file.id+' .progress p').html('处理中...');
		}
		else
		{
			$('#file-'+file.id+' .progress p').html(file.percent+'%');
		}
		$('#file-'+file.id+' .progress .progress-bar').css({"width":file.percent+"%"});
	});
	
	//单个上传完成后
	uploader.bind('FileUploaded',function(uploader,file,res){
		rearr = JSON.parse(res.response);
		html = '<a href="'+rearr.folder+rearr.filename+'" target="_blank"><img class="img" src="'+rearr.folder+rearr.thumbfile+'" /></a>';
		$('#file-'+file.id).prepend(html);
		$('#file-'+file.id).addClass("upfiles_li_on");
		$('#file-'+file.id+' .progress .progress-bar').removeClass("active");
		$('#file-'+file.id+' .word .fr').html('<a href="'+rearr.folder+rearr.filename+'" target="_blank">查看</a>');
		//rearr = JSON.parse(res.response);
		//console.log(rearr)
	});
	
	//全部上传完成后
	uploader.bind('UploadComplete',function(uploader,file){
		$(".upfiles_zw").hide();
		tip_msg("附件上传完成");
	});
</script>

<!-- elseif($type == "standard") -->
<script>
function check_upfile_standard()
{
	var filePaths = document.getElementById("iframeUpload").files;
	var arrnum = filePaths.length;
	
	//限制上传文件类型
	for(i=0;i<arrnum;i++)
	{
		var poi = filePaths[i].name;
		var fileAccept = poi.split(".")[1];
		fileAccept=fileAccept.toLowerCase();
		if(fileAccept!="jpg" && fileAccept!="jpeg" && fileAccept!="gif" && fileAccept!="png")
		{
			tip_alert("包含非法文件类型!");
			return false;
		}
	}
	
	//限制上传图片数量
	if(arrnum>20)
	{
		tip_alert("一次最多只能选择20张图片")
		return false;
	}
	uploading();
}
function uploading()
{
	$(".show_step").html("<img src='images/loading.gif' border='0' align='absmiddle'> 正在保存数据，如果网页没有动静请刷新...");
	$(".creat_button").attr("disabled","disabled");
}
</script>

<div class="page_pad">
  <table class="qg_notice">
    <tr>
      <td>您正在使用浏览器内置的标准上传工具。使用全新的上传工具可支持修改上传参数、拖放上传等。<a href="{:$mainlink}?file=upfiles&act=upfiles&type=new{if($sysgroupid)}&sysgroupid={:$sysgroupid}{end}{if($single)}&single={:$single}{end}">改用新的上传工具</a>。<!-- if($single) --><a class="red" href="{:$mainlink}?file=upfiles&act=upfiles&sysgroupid={:$sysgroupid}&cateid={:$cateid}{if($additonid)}&additonid={:$additonid}{end}&type=standard" target="_blank">在新窗口打开</a><!-- end --></td>
    </tr>
  </table>
  
  <form method="post" action="{:$mainlink}?file=upfiles&act=upfilesok{if($single)}&single={:$single}{end}" enctype="multipart/form-data" onsubmit="return check_upfile_{:$type}()">
  <div class="content_box">
    <div class="content_bor">
      <table class="ctable">
        <tr>
          <td class="left">系统组：</td>
          <td class="right">
            <select class="upselect" name="sysgroupid" onchange="changese(this)">
              <option value="0">未选择</option>
              <!-- $sysmenu AS $key=>$value -->
              <option value="{:$value[id]}" {if($value[id]==$sysgroupid)}selected="selected"{end}>{:$value[groupname]}</option>
              <!-- end -->
            </select>
          </td>
        </tr>
        <!-- if($sysgroupid) -->
        <tr>
          <td class="left">分类：</td>
          <td class="right">
          <!-- if($msglist) -->
          <input type="hidden" name="cateid" id="cateid" value="{:$cateid}" />
          <select class="upselect">
            <!-- $catelist AS $key=>$value -->
            <option value="{:$value[id]}" {if($value[id]==$cateid)}selected="selected"{end} disabled="disabled">{:$value[space]}{:$value[catename]}</option>
            <!-- end -->
          </select>
          
          <select class="upselect" name="additonid" id="additonid" style="max-width:250px;">
            <option value="0">请选择所属内容</option>
            <!-- $msglist AS $key=>$value -->
            <option value="{:$value[id]}" {if($value[id]==$additonid)}selected="selected"{end}>{:$value[subject]}</option>
            <!-- end -->
          </select>
          
          <!-- else -->
          <select class="upselect" name="cateid" id="cateid">
            <!-- $catelist AS $key=>$value -->
            <option value="{:$value[id]}" {if($value[id]==$cateid)}selected="selected"{end}>{:$value[space]}{:$value[catename]}</option>
            <!-- end -->
          </select>
          <!-- end -->
        </tr>
        <!-- end -->
        <tr>
          <td class="left">选择图片：</td>
          <td class="right"><input type="file" id="iframeUpload" name="iframeUpload[]" accept="image/jpeg,image/jpg,image/gif,image/png" multiple/></td>
        </tr>
      </table>
    </div>
  </div>
  
  <div class="gbutton_div"><button type="submit" class="gbutton gbutton_dblue gbutton_add creat_button">确认上传</button> &nbsp; <span class="show_step" style="color:red;"><img src="images/loading.gif" style="visibility:hidden;" /></span></div>
  </form>
</div><!--page_pad-->
<!-- end -->
<!-- end -->

<!-- inc:frame.bottom -->